package oj;

import java.util.Scanner;

public class Day14计算日期到天数转换 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] months={0,31,28,31,30,31,30,31,31,30,31,30,31};
        while (sc.hasNext()) {
            String str=sc.nextLine();
            String[] s=str.split(" ");
            int count = 0;
            if(isLeap(Integer.parseInt(s[0]))){
                months[2]++;
            }
            for (int i = 0; i < Integer.parseInt(s[1]); i++) {
                count += months[i];
            }
            count+=Integer.parseInt(s[2]);
            System.out.println(count);
        }
    }
    private static boolean isLeap(int year){
        return (year%4==0&&year%100!=0) || year%400==0;
    }
}
